package com.powernode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powernode.domain.Member;
import com.powernode.mapper.MemberMapper;
import com.powernode.service.MemberService;
import com.powernode.util.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    /*
     * 更新小程序会员的头像和昵称
     * @author RenBoQing
     * @date 2024/9/22 11:24
     * @param member
     * @return boolean
     */
    @Override
    public boolean modifyMemberInfoByOpenId(Member member) {
        // 获取当前用户的openid
        String memberOpenId = AuthUtils.getMemberOpenId();
        // 更新当前小程序用户的头像和昵称
        return memberMapper.update(member, new LambdaUpdateWrapper<Member>().eq(Member::getOpenId, memberOpenId)
        ) > 0;
    }
}
